<?php

use Illuminate\Support\Facades\Route;

/*
|--------------------------------------------------------------------------
| Web Routes
|--------------------------------------------------------------------------
|
| Here is where you can register web routes for your application. These
| routes are loaded by the RouteServiceProvider within a group which
| contains the "web" middleware group. Now create something great!
|
 */

/**
 * 需要加入 rbac 控制的路由置于此处
 */
Route::group([
    'middleware' => ['install.check', 'session.check', 'rbac'],
    'as'         => 'rbac',
], function ($route) {
    //控制台
    $route->get('console', 'Admin\IndexController@console');
    $route->group(['prefix' => 'admin'], function ($route) {
        //菜单管理
        $route->get('menu/list', 'Admin\AdministratorController@menuList');
        $route->get('menu/add', 'Admin\AdministratorController@menuAddView');
        $route->post('menu/add', 'Admin\AdministratorController@menuAdd');
        $route->get('menu/update/{id}', 'Admin\AdministratorController@menuUpdateView');
        $route->post('menu/update/{id}', 'Admin\AdministratorController@menuUpdate');
        $route->post('menu/del/{id}', 'Admin\AdministratorController@menuDel');
        //角色管理
        $route->get('role/list', 'Admin\AdministratorController@roleList');
        $route->get('role/add', 'Admin\AdministratorController@roleAddView');
        $route->post('role/add', 'Admin\AdministratorController@roleAdd');
        $route->get('role/update/{id}', 'Admin\AdministratorController@roleUpdateView');
        $route->post('role/update/{id}', 'Admin\AdministratorController@roleUpdate');
        $route->post('role/del/{id}', 'Admin\AdministratorController@roleDel');
        //权限管理
        $route->get('permission/list', 'Admin\AdministratorController@permissionList');
        $route->get('permission/add', 'Admin\AdministratorController@permissionAddView');
        $route->post('permission/add', 'Admin\AdministratorController@permissionAdd');
        $route->get('permission/update/{id}', 'Admin\AdministratorController@permissionUpdateView');
        $route->post('permission/update/{id}', 'Admin\AdministratorController@permissionUpdate');
        $route->post('permission/del/{id}', 'Admin\AdministratorController@permissionDel');
        //管理员管理
        $route->get('administrator/list', 'Admin\AdministratorController@administratorList');
        $route->get('administrator/add', 'Admin\AdministratorController@administratorAddView');
        $route->post('administrator/add', 'Admin\AdministratorController@administratorAdd');
        $route->get('administrator/update/{id}', 'Admin\AdministratorController@administratorUpdateView');
        $route->post('administrator/update/{id}', 'Admin\AdministratorController@administratorUpdate');
        $route->post('administrator/del/{id}', 'Admin\AdministratorController@administratorDel');
        //配置管理
        $route->get('config/list', 'Admin\ConfigController@configList');
        $route->get('config/add', 'Admin\ConfigController@configAddView');
        $route->post('config/add', 'Admin\ConfigController@configAdd');
        $route->get('config/update/{id}', 'Admin\ConfigController@configUpdateView');
        $route->post('config/update/{id}', 'Admin\ConfigController@configUpdate');
        $route->post('config/del/{id}', 'Admin\ConfigController@configDel');


        //应用管理
        $route->get('app/list', 'Admin\AppController@appList');
        $route->get('app/add', 'Admin\AppController@appAddView');
        $route->post('app/add', 'Admin\AppController@appAdd');
        $route->get('app/update/{id}', 'Admin\AppController@appUpdateView');
        $route->post('app/update/{id}', 'Admin\AppController@appUpdate');
        $route->post('app/del/{id}', 'Admin\AppController@appDel');
        $route->get('app/puv/{id}', 'Admin\AppController@puv');

        // Refer管理
        $route->get('refer/list', 'Admin\ReferController@referList');
        $route->get('refer/add', 'Admin\ReferController@referAddView');
        $route->post('refer/add', 'Admin\ReferController@referAdd');
        $route->get('refer/update/{id}', 'Admin\ReferController@referUpdateView');
        $route->post('refer/update/{id}', 'Admin\ReferController@referUpdate');
        $route->post('refer/del/{id}', 'Admin\ReferController@referDel');

        // 分享链接管理
        $route->get('channel/list', 'Admin\ChannelController@channelList');
        $route->get('channel/add', 'Admin\ChannelController@channelAddView');
        $route->post('channel/add', 'Admin\ChannelController@channelAdd');
        $route->get('channel/update/{id}', 'Admin\ChannelController@channelUpdateView');
        $route->post('channel/update/{id}', 'Admin\ChannelController@channelUpdate');
        $route->post('channel/del/{id}', 'Admin\ChannelController@channelDel');
        $route->get('channel/puv/{id}', 'Admin\ChannelController@puv');
        $route->get('channel/log-summary', 'Admin\ChannelController@logSummary');

        // ajax 接口 button更新 微信 浏览器 分享控制
        $route->post('channel/updateFlag', 'Admin\ChannelController@updateFlag');


        // 命中贷超黑名单记录
        $route->get('access-log/list', 'Admin\BlackAccessLogController@logList');
        $route->get('statistics/list', 'Admin\StatisticsController@byDate');

        // 接口调用
        $route->get('app/kouzi', 'Admin\AppController@getKouZiResult');


        // 白名单管理
        $route->get('whitelist/list', 'Admin\WhiteListController@whiteList');
        $route->get('whitelist/add', 'Admin\WhiteListController@whiteAddView');
        $route->post('whitelist/add', 'Admin\WhiteListController@whiteAdd');
        $route->get('whitelist/update/{id}', 'Admin\WhiteListController@whiteUpdateView');
        $route->post('whitelist/update/{id}', 'Admin\WhiteListController@whiteUpdate');
        $route->post('whitelist/del/{id}', 'Admin\WhiteListController@whiteDel');
    });

});
Route::group([
    'middleware' => ['install.check', 'session.check'],
    'as'         => 'base',
], function ($route) {
    //框架
    $route->get('/', 'Admin\IndexController@index');
    //403无访问权限
    $route->get('403', 'Admin\IndexController@noPermission');
    //修改个人信息
    $route->get('edit/info/{id}', 'Admin\AdministratorController@editInfoView');
    $route->post('edit/info/{id}', 'Admin\AdministratorController@editInfo');
    //图片上传
    $route->post('admin/upload', 'Admin\IndexController@upload');
    $route->post('admin/wangeditor/upload', 'Admin\IndexController@wangeditorUpload');
    //退出登录
    $route->get('logout', 'Admin\AdministratorController@logout');
});
Route::group([
    'middleware' => ['install.check'],
    'as'         => 'base',
], function ($route) {
    // 登录
    $route->get('login', 'Admin\AdministratorController@login');
    $route->post('login', 'Admin\AdministratorController@checkLogin');
});

// 图标库（开发者用）
Route::get('icon', function () {
    return view('admin.icon');
});
// 安装向导
Route::get('install', 'InstallController@index')->name('installView');
Route::post('install/1', 'InstallController@setEnviroment')->name('setEnviroment');
Route::post('install/2', 'InstallController@startInstall')->name('startInstall');


Route::get('t/{keyword}', 'Url\UrlController@index')->name("url/index");
Route::get('{keyword}', 'Url\UrlController@index')->name("url/index2");
